<?php 

    function getpage($count, $pagesize = 10) {
      $p = new \Think\Page($count, $pagesize);
      $p->setConfig('header', '<li class="rows">共<b>%TOTAL_ROW%</b>条记录&nbsp;第<b>%NOW_PAGE%</b>页/共<b>%TOTAL_PAGE%</b>页</li>');
      $p->setConfig('prev', '上一页');
      $p->setConfig('next', '下一页');
      $p->setConfig('last', '末页');
      $p->setConfig('first', '首页');
      $p->setConfig('theme', '%FIRST%%UP_PAGE%%LINK_PAGE%%DOWN_PAGE%%END%%HEADER%');
      $p->lastSuffix = false;//最后一页不显示为总页数
      return $p;
  }


  function Post($curlPost,$url){
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_NOBODY, true);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);
    $return_str = curl_exec($curl);
    curl_close($curl);
    return $return_str;
}
function xml_to_array($xml){
  $reg = "/<(\w+)[^>]*>([\\x00-\\xFF]*)<\\/\\1>/";
  if(preg_match_all($reg, $xml, $matches)){
    $count = count($matches[0]);
    for($i = 0; $i < $count; $i++){
    $subxml= $matches[2][$i];
    $key = $matches[1][$i];
      if(preg_match( $reg, $subxml )){
        $arr[$key] = xml_to_array( $subxml );
      }else{
        $arr[$key] = $subxml;
      }
    }
  }
  return $arr;
}
function random($length = 6 , $numeric = 0) {
  PHP_VERSION < '4.2.0' && mt_srand((double)microtime() * 1000000);
  if($numeric) {
    $hash = sprintf('%0'.$length.'d', mt_rand(0, pow(10, $length) - 1));
  } else {
    $hash = '';
    $chars = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789abcdefghjkmnpqrstuvwxyz';
    $max = strlen($chars) - 1;
    for($i = 0; $i < $length; $i++) {
      $hash .= $chars[mt_rand(0, $max)];
    }
  }
  return $hash;
}




function GetRandStr($len) 
{ 
    $chars = array( 
        // "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",  
        // "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",  
        // "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G",  
        // "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",  
        // "S", "T", "U", "V", "W", "X", "Y", "Z",
         "1", "2",  
        "3", "4", "5", "6", "7", "8", "9" 
    ); 
    $charsLen = count($chars) - 1; 
    shuffle($chars);   
    $output = ""; 
    for ($i=0; $i<$len; $i++) 
    { 
        $output .= $chars[mt_rand(0, $charsLen)]; 
    }  
    return $output;  
} 

 ?>
 